
/*********************
 *      INCLUDES
 *********************/
#include <stdio.h>
#include <stdlib.h>
#include "setting_desktop.h"


LV_FONT_DECLARE(font_32_ganggang)
LV_FONT_DECLARE(font_24_menu_btn)
LV_FONT_DECLARE(font_16_menu_btn)
LV_FONT_DECLARE(font_16_all)
static void btn_back_cb(lv_event_t *e)
{
    if(e->code == LV_EVENT_CLICKED)
    {
        lv_app_anim_out_all(lv_scr_act(), 0);
        create_main_desktop();
    }
}

static void create_window(void)
{
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_radius(&style, 0);
    lv_style_set_bg_color(&style, lv_color_hex(0xffffff));
    lv_style_set_border_width(&style, 2);
    lv_style_set_border_color(&style, lv_color_hex(0x000000));

    lv_style_set_pad_top(&style, 2);
    lv_style_set_pad_bottom(&style, 2);
    lv_style_set_pad_left(&style, 2);
    lv_style_set_pad_right(&style, 2);

    lv_obj_t* bar = lv_bar_create(lv_scr_act());
    lv_bar_set_range(bar, 0, 100);
    lv_obj_add_style(bar, &style, LV_STATE_DEFAULT);
    lv_obj_set_size(bar, 18, 200);
    lv_obj_align(bar, LV_ALIGN_LEFT_MID, 20, 0);

    lv_obj_set_style_radius(bar, 0, LV_PART_INDICATOR);
    lv_obj_set_style_bg_color(bar, lv_color_hex(0x00ff00), LV_PART_INDICATOR);
    lv_bar_set_value(bar, 80, LV_ANIM_OFF);

    lv_obj_t *title = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(title, &font_32_ganggang, LV_STATE_DEFAULT);
    lv_label_set_text(title, "罡罡冰壶");
    lv_obj_set_style_text_color(title, lv_color_hex(0xff0000), LV_STATE_DEFAULT);
    lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 20);

    // ------------储气室压力设定------------ //
    lv_obj_t *label_0_p0 = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(label_0_p0, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_0_p0, "储气室压力设定:");
    lv_obj_align(label_0_p0, LV_ALIGN_TOP_LEFT, 48, 64);

    lv_obj_t *label_0_p1 = lv_label_create(lv_scr_act());
    lv_label_set_text(label_0_p1, "0.00");
    lv_obj_set_style_text_color(label_0_p1, lv_color_hex(0x0000ff), LV_STATE_DEFAULT);
    lv_obj_align_to(label_0_p1, label_0_p0, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    lv_obj_t *label_0_p2 = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(label_0_p2, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_0_p2, "KPa");
    lv_obj_align_to(label_0_p2, label_0_p1, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    // ------------悬浮室压力设定------------ //
    lv_obj_t *label_2_p0 = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(label_2_p0, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_2_p0, "悬浮室压力设定:");
    lv_obj_align_to(label_2_p0, label_0_p0, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 4);

    lv_obj_t *label_2_p1 = lv_label_create(lv_scr_act());
    lv_label_set_text(label_2_p1, "0.00");
    lv_obj_set_style_text_color(label_2_p1, lv_color_hex(0x0000ff), LV_STATE_DEFAULT);
    lv_obj_align_to(label_2_p1, label_2_p0, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    lv_obj_t *label_2_p2 = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(label_2_p2, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_2_p2, "KPa");
    lv_obj_align_to(label_2_p2, label_2_p1, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    // ------------气泵转速设定------------ //
    lv_obj_t *label_1_p0 = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(label_1_p0, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_1_p0, "气泵转速设定:");
    lv_obj_align_to(label_1_p0, label_2_p0, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20);

    lv_obj_t *label_1_p1 = lv_label_create(lv_scr_act());
    lv_label_set_text(label_1_p1, "0000.0");
    lv_obj_set_style_text_color(label_1_p1, lv_color_hex(0x0000ff), LV_STATE_DEFAULT);
    lv_obj_align_to(label_1_p1, label_1_p0, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    lv_obj_t *label_1_p2 = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(label_1_p2, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_1_p2, "r/m");
    lv_obj_align_to(label_1_p2, label_1_p1, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    // ------------排气阀开度设定------------ //
    lv_obj_t *label_3_p0 = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(label_3_p0, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_3_p0, "排气阀开度设定:");
    lv_obj_align_to(label_3_p0, label_1_p0, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 4);

    lv_obj_t *label_3_p1 = lv_label_create(lv_scr_act());
    lv_label_set_text(label_3_p1, "000.0");
    lv_obj_set_style_text_color(label_3_p1, lv_color_hex(0x0000ff), LV_STATE_DEFAULT);
    lv_obj_align_to(label_3_p1, label_3_p0, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    lv_obj_t *label_3_p2 = lv_label_create(lv_scr_act());
    lv_label_set_text(label_3_p2, "%");
    lv_obj_align_to(label_3_p2, label_3_p1, LV_ALIGN_OUT_RIGHT_MID, 0, 0);

    // ------------PID自动------------ //
    lv_obj_t *btn_auto = lv_btn_create(lv_scr_act());
	lv_obj_set_size(btn_auto, 60, 36);
	lv_obj_set_style_radius(btn_auto, 0, LV_PART_MAIN);
	lv_obj_t *label_auto = lv_label_create(btn_auto);
	lv_obj_center(label_auto);
	lv_obj_set_style_text_font(label_auto, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_auto, " PID\n自动");
    lv_obj_align(btn_auto,LV_ALIGN_TOP_RIGHT, -20, 66);
    lv_obj_add_event_cb(btn_auto, btn_back_cb, LV_EVENT_CLICKED, NULL);

    // ------------手动调试------------ //
    lv_obj_t *btn_manual = lv_btn_create(lv_scr_act());
	lv_obj_set_size(btn_manual, 60, 36);
	lv_obj_set_style_radius(btn_manual, 0, LV_PART_MAIN);
	lv_obj_t *label_manual = lv_label_create(btn_manual);
	lv_obj_center(label_manual);
	lv_obj_set_style_text_font(label_manual, &font_16_all, LV_STATE_DEFAULT);
    lv_label_set_text(label_manual, "手动\n调试");
    lv_obj_align(btn_manual,LV_ALIGN_TOP_RIGHT, -20, 126);
    lv_obj_add_event_cb(btn_manual, btn_back_cb, LV_EVENT_CLICKED, NULL);

    // ------------返回------------ //
    lv_obj_t *btn_back = lv_btn_create(lv_scr_act());
	lv_obj_set_size(btn_back, 60, 20);
	lv_obj_set_style_radius(btn_back, 0, LV_PART_MAIN);
	lv_obj_t *label_back = lv_label_create(btn_back);
	lv_obj_center(label_back);
	lv_obj_set_style_text_font(label_back, &font_16_menu_btn, LV_STATE_DEFAULT);
    lv_label_set_text(label_back, "返回");
    lv_obj_align(btn_back,LV_ALIGN_BOTTOM_RIGHT, -20, -20);
    lv_obj_add_event_cb(btn_back, btn_back_cb, LV_EVENT_CLICKED, NULL);
}

/*
 *  函数名：  void create_setting_desktop(void)
 *  输入参数：无
 *  返回值：  无
 *  函数作用：应用初始化入口
*/
void create_setting_desktop(void)
{
    create_window();
}
